package com.k.kpp.config.http;

import org.apache.commons.pool2.BasePooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.hc.client5.http.classic.HttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;


/**
 * @author kivil
 */
public class HttpClientFactory extends BasePooledObjectFactory<HttpClient> {
    private HttpClientProperties config;

    public HttpClientFactory(HttpClientProperties config) {
        System.out.println("http.client:" + config.toString());
        this.config = config;
    }


    @Override
    public HttpClient create() throws Exception {
        CloseableHttpClient httpClient = HttpClients.custom()
                //.setConnectionManager(cm)
                .setConnectionManagerShared(true)
                .build();
        return httpClient;
    }

    @Override
    public PooledObject<HttpClient> wrap(HttpClient httpClient) {
        return null;
    }
}
